﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace WF
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String loginname = Request["loginname"];
            String passwd = Request["loginpwd"];

            if (loginname != null && passwd != null)
            {
                doLogin(loginname, passwd);
            }
        }

        public void doLogin(String loginname, String passwd)
        {
            string uid = "";
            bool result = new BusWEB.WFInterface.Users().Login(loginname, passwd, out uid);// new BLL.doLogin().isLogin(loginname, passwd);
            //int result = 1;
            if (result)
            {
                //string userid = uid;// result.ToString();
                System.Web.Security.FormsAuthentication.SetAuthCookie(uid, false);
                Response.Redirect("Default.aspx", false);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "js", "<script language=\"javascript\">alert('登錄發生錯誤：" + uid + "！');</script>");
                return;
            }
        }
    }
}
